<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="chapter.css"?><chapter id="elements.xml">
  <title>Elements reference guide</title>
  <simplesect>
    <para>This short reference guide to Relax NG elements presents each of the elements composing the XML syntax for Relax NG by alphabetical order. Note that the synopsis given for each element is generated from the Relax NG schema for Relax NG and dooesn't capture the restrictions applied after simplification. The simplification process and restrictions are detailed in &quot;Chapter 15: Simplification And Restrictions&quot;. The main restrictions are also mentioned for each element in this chapter in the section titled &quot;Restrictions&quot;.</para>
  </simplesect>
  <sect1><title>Elements</title><refentry id="ch15-anyName">
      <refmeta>
        <refentrytitle>anyName</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2606497">
          <primary>anyName</primary>
        </indexterm>
        <refname>anyName</refname>
        <refpurpose>Name class accepting any name.</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>name-class</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element anyName
{
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   ( ( element * - rng:* { ... }* ) &amp; element except { ... }? )
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>attribute</literal>, <literal>choice</literal>, <literal>element</literal>, <literal>except</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>*-nameClass</para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>anyName</literal> name class matches any name from any namespace. This wild spectrum may be restricted by embedding <literal>except</literal> name classes.</para>
      </refsect1>
      <refsect1>
        <title>Restrictions:</title>
        <para>Within the scope of an element, the name classes of attributes cannot overlap. The same restriction applies to name classes of elements when these elements are combined by <literal>interleave</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
       &lt;element&gt;
        &lt;anyName/&gt;
        &lt;ref name=&quot;anything&quot;/&gt;
       &lt;/element&gt;
        
       &lt;element&gt;
        &lt;anyName&gt;
          &lt;except&gt;
            &lt;nsName ns=&quot;&quot;/&gt;
            &lt;nsName ns=&quot;http://eric.van-der-vlist.com/ns/library&quot;/&gt;
            &lt;nsName ns=&quot;http://eric.van-der-vlist.com/ns/person&quot;/&gt;
          &lt;/except&gt;
        &lt;/anyName&gt;
        &lt;ref name=&quot;anything&quot;/&gt;
       &lt;/element&gt;
      
       &lt;attribute&gt;
         &lt;anyName/&gt;
       &lt;/attribute&gt;</programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
        <varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited. Note that although <literal>datatypeLibrary</literal> is allowed in <literal>anyName</literal> to maintain a coherence with other Relax NG elements, it has no direct consequence on <literal>anyName</literal> itself nor on the name class definitions which might be embedded.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The <literal>ns</literal> attribute defines the default namespace for the elements defined in a portion of schema. The value of <literal>ns</literal> is inherited. Note that although <literal>ns</literal> is allowed in <literal>anyName</literal> it has no direct consequence on <literal>anyName</literal> itself which does always allow any name from any namespace and may only have a consequence on name class definitions embedded in this one.&quot;</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry><refentry id="ch15-attribute">
      <refmeta>
        <refentrytitle>attribute</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2605551">
          <primary>attribute</primary>
        </indexterm>
        <refname>attribute</refname>
        <refpurpose>Pattern matching an attribute.</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>pattern</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element attribute
{
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   (
      attribute name { xsd:QName }
    | (
         ( element * - rng:* { ... }* )
       &amp; (
            element name { ... }
          | element anyName { ... }
          | element nsName { ... }
          | element choice { ... }
         )
      )
   ),
   (
      ( element * - rng:* { ... }* )
    &amp; (
         element element { ... }
       | element attribute { ... }
       | element group { ... }
       | element interleave { ... }
       | element choice { ... }
       | element optional { ... }
       | element zeroOrMore { ... }
       | element oneOrMore { ... }
       | element list { ... }
       | element mixed { ... }
       | element ref { ... }
       | element parentRef { ... }
       | element empty { ... }
       | element text { ... }
       | element value { ... }
       | element data { ... }
       | element notAllowed { ... }
       | element externalRef { ... }
       | element grammar { ... }
      )?
   )
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>attribute</literal>, <literal>choice</literal>, <literal>define</literal>, <literal>element</literal>, <literal>except</literal>, <literal>group</literal>, <literal>interleave</literal>, <literal>list</literal>, <literal>mixed</literal>, <literal>oneOrMore</literal>, <literal>optional</literal>, <literal>start</literal>, <literal>zeroOrMore</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>attribute</para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>attribute</literal> pattern matches an attribute. The name of the attribute may be defined either through a <literal>name</literal> attribute or through a name class.</para>
      </refsect1>
      <refsect1>
        <title>Restrictions:</title>
        <para>
          <itemizedList>
            <listItem>
              <para>After simplification, attributes patterns can only contain patterns relevant for text nodes.</para>
            </listItem>
            <listItem>
              <para>Attributes cannot be duplicated, either directly or through overlaping name classes.</para>
            </listItem>
            <listItem>
              <para>Attributes which have an infinite name class (<literal>anyName</literal> or <literal>nsName</literal>) must be enclosed in a <literal>oneOrMore</literal> (or <literal>zeroOrMore</literal> before simplification) pattern.</para>
            </listItem>
          </itemizedList>
        </para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
        &lt;attribute name=&quot;id&quot;/&gt;
        
        &lt;attribute name=&quot;xml:lang&quot;&gt;
          &lt;data type=&quot;language&quot;/&gt;
         &lt;/attribute&gt;

        &lt;attribute&gt;
          &lt;anyName/&gt;
        &lt;/attribute&gt;
      </programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
          
        <varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>name</literal>
            </term>
            <listitem>
              <para>When <literal>name</literal> is specified, the  <literal>attribute</literal> pattern matches only attributes with this name (<literal>name</literal> is a shortcut to define a single name as a name class for the <literal>attribute</literal> pattern).</para>
              <para>Both <literal>name</literal> and the definition of a name class cannot be specified (they are exclusive options).</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The ns attribute defines the namespace of the attribute. Note that in the context of the <literal>ns</literal> pattern, the ns attribute is not inherited.</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry><refentry id="ch15-choice2">
      <refmeta>
        <refentrytitle>choice (in the context of a name-class)</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2606532">
          <primary>choice (in the context of a name-class)</primary>
        </indexterm>
        <refname>choice (in the context of a name-class)</refname>
        <refpurpose>Choice between name classes</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>name-class</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element choice
{
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   (
      ( element * - rng:* { ... }* )
    &amp; (
         element name { ... }
       | element anyName { ... }
       | element nsName { ... }
       | element choice { ... }
      )+
   )
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>attribute</literal>, <literal>choice</literal>, <literal>element</literal>, <literal>except</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>nameClass|nameClass</para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>choice</literal> name class performs a choice between several name classes: a name will match <literal>choice</literal> if and only if it matches at least one of the sub-name classes.</para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
 &lt;element&gt;
   &lt;choice&gt;
     &lt;nsName ns=&quot;http://eric.van-der-vlist.com/ns/library&quot;/&gt;
     &lt;nsName ns=&quot;http://eric.van-der-vlist.com/ns/person&quot;/&gt;
   &lt;/choice&gt;
   &lt;ref name=&quot;anything&quot;/&gt;
 &lt;/element&gt;
      </programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
        <varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited. Note that although <literal>datatypeLibrary</literal> is allowed in <literal>choice</literal> to maintain a coherence with other Relax NG elements, it has no direct consequence on <literal>choice</literal> itself nor on the name class definitions which might be embedded.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The <literal>ns</literal> attribute defines the default namespace for the elements defined in a portion of schema. The value of <literal>ns</literal> is inherited.</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry><refentry id="ch15-choice1">
      <refmeta>
        <refentrytitle>choice (in the context of a pattern)</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2605639">
          <primary>choice (in the context of a pattern)</primary>
        </indexterm>
        <refname>choice (in the context of a pattern)</refname>
        <refpurpose><literal>choice</literal> pattern</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>pattern</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element choice
{
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   (
      ( element * - rng:* { ... }* )
    &amp; (
         element element { ... }
       | element attribute { ... }
       | element group { ... }
       | element interleave { ... }
       | element choice { ... }
       | element optional { ... }
       | element zeroOrMore { ... }
       | element oneOrMore { ... }
       | element list { ... }
       | element mixed { ... }
       | element ref { ... }
       | element parentRef { ... }
       | element empty { ... }
       | element text { ... }
       | element value { ... }
       | element data { ... }
       | element notAllowed { ... }
       | element externalRef { ... }
       | element grammar { ... }
      )+
   )
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>attribute</literal>, <literal>choice</literal>, <literal>define</literal>, <literal>element</literal>, <literal>except</literal>, <literal>group</literal>, <literal>interleave</literal>, <literal>list</literal>, <literal>mixed</literal>, <literal>oneOrMore</literal>, <literal>optional</literal>, <literal>start</literal>, <literal>zeroOrMore</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>pattern|pattern</para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>choice</literal> pattern defines a choice between different patterns: it matches a node if and only if at least one of its sub-pattern matches this node.</para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
   &lt;element name=&quot;name&quot;&gt;
    &lt;choice&gt;
     &lt;text/&gt;
     &lt;group&gt;
      &lt;element name=&quot;first&quot;&gt;&lt;text/&gt;&lt;/element&gt;
      &lt;optional&gt;
        &lt;element name=&quot;middle&quot;&gt;&lt;text/&gt;&lt;/element&gt;
      &lt;/optional&gt;
      &lt;element name=&quot;last&quot;&gt;&lt;text/&gt;&lt;/element&gt;
     &lt;/group&gt;
    &lt;/choice&gt;
   &lt;/element&gt;

   &lt;attribute name=&quot;available&quot;&gt;
     &lt;choice&gt;
      &lt;value&gt;true&lt;/value&gt;
      &lt;value&gt;false&lt;/value&gt;
      &lt;value&gt;who knows?&lt;/value&gt;
     &lt;/choice&gt;
    &lt;/attribute&gt;

    &lt;start&gt;
      &lt;ref name=&quot;libraryElement&quot;/&gt;
      &lt;ref name=&quot;bookElement&quot;/&gt;
    &lt;/start&gt;
      </programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
        <varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The <literal>ns</literal> attribute defines the default namespace for the elements defined in a portion of schema. The value of <literal>ns</literal> is inherited.</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry><refentry id="ch15-data">
      <refmeta>
        <refentrytitle>data</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2605871">
          <primary>data</primary>
        </indexterm>
        <refname>data</refname>
        <refpurpose><literal>data</literal> pattern</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>pattern</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element data
{
   attribute type { xsd:NCName },
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   (
      ( element * - rng:* { ... }* )
    &amp; ( element param { ... }*, element except { ... }? )
   )
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>attribute</literal>, <literal>choice</literal>, <literal>define</literal>, <literal>element</literal>, <literal>except</literal>, <literal>group</literal>, <literal>interleave</literal>, <literal>list</literal>, <literal>mixed</literal>, <literal>oneOrMore</literal>, <literal>optional</literal>, <literal>start</literal>, <literal>zeroOrMore</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>datatypeName param exceptPattern</para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>data</literal> pattern matches a single text node and gives the possibility to restrict its values. This is different from the <literal>text</literal> pattern which matches zero or more text nodes and doesn't give any possibility to restrict the values of these text nodes. The restrictions are applied through the <literal>type</literal> attribute which defines the datatype and the <literal>param</literal> and <literal>except</literal> children patterns.</para>
      </refsect1>
      <refsect1>
        <title>Restrictions:</title>
        <para>The <literal>data</literal> pattern is meant for data oriented applications and can't be used in mixed content models.</para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
    &lt;attribute name=&quot;see-also&quot;&gt;
     &lt;list&gt;
      &lt;data type=&quot;token&quot;/&gt;
     &lt;/list&gt;
    &lt;/attribute&gt;
    
    &lt;attribute name=&quot;id&quot;&gt;
     &lt;data type=&quot;NMTOKEN&quot;&gt;
       &lt;param name=&quot;maxLength&quot;&gt;16&lt;/param&gt;
     &lt;/data&gt;
    &lt;/attribute&gt;

    &lt;element name=&quot;isbn&quot;&gt;
     &lt;data type=&quot;token&quot;&gt;
      &lt;except&gt;
       &lt;value&gt;0836217462&lt;/value&gt;
      &lt;/except&gt;
     &lt;/data&gt;
    &lt;/element&gt;
      </programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
          
        <varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The <literal>ns</literal> attribute defines the default namespace for the elements defined in a portion of schema. The value of <literal>ns</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>type</literal>
            </term>
            <listitem>
              <para>The <literal>type</literal> attribute specifies the datatype used for evaluating the <literal>data</literal> pattern. Any text node which value isn't valid per this datatype fails to match the <literal>data</literal> pattern.</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry><refentry id="ch15-define">
      <refmeta>
        <refentrytitle>define</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2606356">
          <primary>define</primary>
        </indexterm>
        <refname>define</refname>
        <refpurpose>Named pattern definition</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>define-element</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element define
{
   attribute name { xsd:NCName },
   ( attribute combine { &quot;choice&quot; | &quot;interleave&quot; }? ),
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   (
      ( element * - rng:* { ... }* )
    &amp; (
         element element { ... }
       | element attribute { ... }
       | element group { ... }
       | element interleave { ... }
       | element choice { ... }
       | element optional { ... }
       | element zeroOrMore { ... }
       | element oneOrMore { ... }
       | element list { ... }
       | element mixed { ... }
       | element ref { ... }
       | element parentRef { ... }
       | element empty { ... }
       | element text { ... }
       | element value { ... }
       | element data { ... }
       | element notAllowed { ... }
       | element externalRef { ... }
       | element grammar { ... }
      )+
   )
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>div</literal>, <literal>grammar</literal>, <literal>include</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>identifier assignMethod pattern</para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>When <literal>define</literal> is embedded in a grammar, it defines a named pattern or combines a new definition with an existing one. Named pattern are global to a <literal>grammar</literal> and can be referenced by <literal>ref</literal> in the scope of their <literal>grammar</literal> and by <literal>parentRef</literal> in the scope of the grammars directly embedded in their <literal>grammar</literal>.</para>
        <para>When <literal>define</literal> is embedded in <literal>include</literal>, the new definition is a redefinition and replaces the definitions from the included grammar unless a <literal>combine</literal> attribute is specified in which case the definitions are combined.</para>
      </refsect1>
      <refsect1>
        <title>Restrictions:</title>
        <para>Named patterns are always global and apply only to patterns and it is not possible to define and make reference to non patterns such as class names or datatype parameters.</para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
  &lt;define name=&quot;born-element&quot;&gt;
    &lt;element name=&quot;born&quot;&gt;
      &lt;text/&gt;
    &lt;/element&gt;
  &lt;/define&gt;

  &lt;define name=&quot;book-content&quot; combine=&quot;interleave&quot;&gt;
    &lt;attribute name=&quot;id&quot;/&gt;
    &lt;attribute name=&quot;available&quot;/&gt;
    &lt;ref name=&quot;isbn-element&quot;/&gt;
    &lt;ref name=&quot;title-element&quot;/&gt;
    &lt;zeroOrMore&gt;
      &lt;ref name=&quot;author-element&quot;/&gt;
    &lt;/zeroOrMore&gt;
    &lt;zeroOrMore&gt;
      &lt;ref name=&quot;character-element&quot;/&gt;
    &lt;/zeroOrMore&gt;
  &lt;/define&gt;
  
  &lt;define name=&quot;isbn-element&quot; combine=&quot;choice&quot;&gt;
    &lt;notAllowed/&gt;
  &lt;/define&gt;
      </programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
          
          
        <varlistentry>
            <term>
              <literal>combine</literal>
            </term>
            <listitem>
              <para>The <literal>combine</literal> attribute specifies how multiple definitions of a named pattern should be combined together. The possible values are <literal>choice</literal> and <literal>interleave</literal>.</para>
              <para>When the <literal>combine</literal> attribute is specified and set to <literal>choice</literal>, multiple definitions of a named pattern are combined in a <literal>choice</literal> pattern. When the <literal>combine</literal> attribute is specified and set to <literal>interleave</literal>, multiple definitions of a named pattern are combined in an <literal>interleave</literal> pattern.</para>
              <para>Note that it is forbidden to specify more than one <literal>define</literal> with the same name and no <literal>combine</literal> attribute or multiple <literal>define</literal> with different values of <literal>combine</literal> attribute.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>name</literal>
            </term>
            <listitem>
              <para>The <literal>name</literal> attribute specifies the name of the named pattern.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The <literal>ns</literal> attribute defines the default namespace for the elements defined in a portion of schema. The value of <literal>ns</literal> is inherited.</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry><refentry id="ch15-div1">
      <refmeta>
        <refentrytitle>div (in the context of a grammar-content)</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2605390">
          <primary>div (in the context of a grammar-content)</primary>
        </indexterm>
        <refname>div (in the context of a grammar-content)</refname>
        <refpurpose>Division (in the context of a <literal>grammar</literal>)</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>grammar-content</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element div
{
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   (
      ( element * - rng:* { ... }* )
    &amp; (
         ( element start { ... } )
       | ( element define { ... } )
       | element div { ... }
       | element include { ... }
      )*
   )
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>div</literal>, <literal>grammar</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>div</para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>div</literal> element is provided to define logical divisions in Relax NG schemas. It has no effect on the validation and its purpose is to define a group of definitions within a <literal>grammar</literal> which may be annotated as a whole.</para>
        <para>In the context of a <literal>grammar</literal>, the content of a <literal>div</literal> element is the same than the content of a <literal>grammar</literal> (this means that <literal>div</literal> elements may be embedded in other <literal>div</literal> elements.</para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
  &lt;grammar xmlns:xhtml=&quot;http://www.w3.org/1999/xhtml&quot; xmlns=&quot;http://relaxng.org/ns/structure/1.0&quot;&gt;
 .../...
   &lt;div&gt;
     &lt;xhtml:p&gt;The content of the book element has been split in two named patterns:&lt;/xhtml:p&gt;
     &lt;define name=&quot;book-start&quot;&gt;
       &lt;attribute name=&quot;id&quot;/&gt;
       &lt;ref name=&quot;isbn-element&quot;/&gt;
       &lt;ref name=&quot;title-element&quot;/&gt;
       &lt;zeroOrMore&gt;
         &lt;ref name=&quot;author-element&quot;/&gt;
       &lt;/zeroOrMore&gt;
     &lt;/define&gt;
     &lt;define name=&quot;book-end&quot;&gt;
       &lt;zeroOrMore&gt;
         &lt;ref name=&quot;author-element&quot;/&gt;
       &lt;/zeroOrMore&gt;
       &lt;zeroOrMore&gt;
         &lt;ref name=&quot;character-element&quot;/&gt;
       &lt;/zeroOrMore&gt;
       &lt;attribute name=&quot;available&quot;/&gt;
     &lt;/define&gt;
   &lt;/div&gt;
 .../...
 &lt;/grammar&gt;
      </programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
        <varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The <literal>ns</literal> attribute defines the default namespace for the elements defined in a portion of schema. The value of <literal>ns</literal> is inherited.</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry><refentry id="ch15-div2">
      <refmeta>
        <refentrytitle>div (in the context of a include-content)</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2605475">
          <primary>div (in the context of a include-content)</primary>
        </indexterm>
        <refname>div (in the context of a include-content)</refname>
        <refpurpose>Division (in the context of an <literal>include</literal>)</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>include-content</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element div
{
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   (
      ( element * - rng:* { ... }* )
    &amp; (
         ( element start { ... } )
       | ( element define { ... } )
       | element div { ... }
      )*
   )
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>div</literal>, <literal>include</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>div</para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>div</literal> element is provided to define logical divisions in Relax NG schemas. It has no effect on the validation and its purpose is to define a group of definitions within an <literal>include</literal> which may be annotated as a whole.</para>
        <para>In the context of an <literal>include</literal>, the content of a <literal>div</literal> element is the same than the content of a <literal>include</literal> (this means that <literal>div</literal> elements may be embedded in other <literal>div</literal> elements.</para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
  &lt;include href=&quot;common.rng&quot;&gt;
 .../...
   &lt;div&gt;
     &lt;xhtml:p&gt;The content of the book element has been split in two named patterns:&lt;/xhtml:p&gt;
     &lt;define name=&quot;book-start&quot;&gt;
       &lt;attribute name=&quot;id&quot;/&gt;
       &lt;ref name=&quot;isbn-element&quot;/&gt;
       &lt;ref name=&quot;title-element&quot;/&gt;
       &lt;zeroOrMore&gt;
         &lt;ref name=&quot;author-element&quot;/&gt;
       &lt;/zeroOrMore&gt;
     &lt;/define&gt;
     &lt;define name=&quot;book-end&quot;&gt;
       &lt;zeroOrMore&gt;
         &lt;ref name=&quot;author-element&quot;/&gt;
       &lt;/zeroOrMore&gt;
       &lt;zeroOrMore&gt;
         &lt;ref name=&quot;character-element&quot;/&gt;
       &lt;/zeroOrMore&gt;
       &lt;attribute name=&quot;available&quot;/&gt;
     &lt;/define&gt;
   &lt;/div&gt;
 .../...
 &lt;/include&gt;
      </programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
        <varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The <literal>ns</literal> attribute defines the default namespace for the elements defined in a portion of schema. The value of <literal>ns</literal> is inherited.</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry><refentry id="ch15-element">
      <refmeta>
        <refentrytitle>element</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2605510">
          <primary>element</primary>
        </indexterm>
        <refname>element</refname>
        <refpurpose>Pattern matching an element</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>pattern</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element element
{
   (
      attribute name { xsd:QName }
    | (
         ( element * - rng:* { ... }* )
       &amp; (
            element name { ... }
          | element anyName { ... }
          | element nsName { ... }
          | element choice { ... }
         )
      )
   ),
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   (
      ( element * - rng:* { ... }* )
    &amp; (
         element element { ... }
       | element attribute { ... }
       | element group { ... }
       | element interleave { ... }
       | element choice { ... }
       | element optional { ... }
       | element zeroOrMore { ... }
       | element oneOrMore { ... }
       | element list { ... }
       | element mixed { ... }
       | element ref { ... }
       | element parentRef { ... }
       | element empty { ... }
       | element text { ... }
       | element value { ... }
       | element data { ... }
       | element notAllowed { ... }
       | element externalRef { ... }
       | element grammar { ... }
      )+
   )
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>attribute</literal>, <literal>choice</literal>, <literal>define</literal>, <literal>element</literal>, <literal>except</literal>, <literal>group</literal>, <literal>interleave</literal>, <literal>list</literal>, <literal>mixed</literal>, <literal>oneOrMore</literal>, <literal>optional</literal>, <literal>start</literal>, <literal>zeroOrMore</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>element</para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>element</literal> pattern matches an element. The name of the element may be defined either through a <literal>name</literal> attribute or through a name class.</para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
      &lt;element name=&quot;born&quot;&gt;
       &lt;text/&gt;
      &lt;/element&gt;

      &lt;element name=&quot;character&quot;&gt;
        &lt;attribute name=&quot;id&quot;/&gt;
        &lt;element name=&quot;name&quot;&gt;
         &lt;text/&gt;
        &lt;/element&gt;
        &lt;element name=&quot;born&quot;&gt;
         &lt;text/&gt;
        &lt;/element&gt;
        &lt;element name=&quot;qualification&quot;&gt;
         &lt;text/&gt;
        &lt;/element&gt;
      &lt;/element&gt;

      &lt;element&gt;
        &lt;anyName/&gt;
        &lt;ref name=&quot;anything&quot;/&gt;
      &lt;/element&gt;
      </programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
          
        <varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>name</literal>
            </term>
            <listitem>
              <para>When <literal>name</literal> is specified, the  <literal>element</literal> pattern matches only elements with this name (<literal>name</literal> is a shortcut to define a single name as a name class for the <literal>element</literal> pattern).</para>
              <para>Both <literal>name</literal> and the definition of a name class cannot be specified (they are exclusive options).</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The <literal>ns</literal> attribute defines the default namespace for the elements defined in a portion of schema. The value of <literal>ns</literal> is inherited.</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry><refentry id="ch15-empty">
      <refmeta>
        <refentrytitle>empty</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2605805">
          <primary>empty</primary>
        </indexterm>
        <refname>empty</refname>
        <refpurpose>Empty content</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>pattern</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element empty
{
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   ( element * - rng:* { ... }* )
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>attribute</literal>, <literal>choice</literal>, <literal>define</literal>, <literal>element</literal>, <literal>except</literal>, <literal>group</literal>, <literal>interleave</literal>, <literal>list</literal>, <literal>mixed</literal>, <literal>oneOrMore</literal>, <literal>optional</literal>, <literal>start</literal>, <literal>zeroOrMore</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>empty</para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>empty</literal> patterns is used to define elements which are empty, i.e. which have no children elements, text nor attributes. Note that it is mandatory to use this pattern in such case (<literal>&lt;element name=&quot;foo&quot;/&gt;</literal> is forbidden) and that there is no such thing as empty attributes (an attribute such as <literal>foo=&quot;&quot;</literal> is considered as having a value which is the empty string rather than be considered as being empty, i.e. having no value).</para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
      &lt;element name=&quot;pageBreak&quot;&gt;
        &lt;empty/&gt;
      &lt;/element&gt;
      </programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
        <varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The <literal>ns</literal> attribute defines the default namespace for the elements defined in a portion of schema. The value of <literal>ns</literal> is inherited.</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry><refentry id="ch15-except2">
      <refmeta>
        <refentrytitle>except (in the context of a except-name-class)</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2606570">
          <primary>except (in the context of a except-name-class)</primary>
        </indexterm>
        <refname>except (in the context of a except-name-class)</refname>
        <refpurpose>Remove a name class from another</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>except-name-class</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element except
{
   (
      ( element * - rng:* { ... }* )
    &amp; (
         element name { ... }
       | element anyName { ... }
       | element nsName { ... }
       | element choice { ... }
      )+
   )
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>anyName</literal>, <literal>nsName</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>-nameClass</para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>except</literal> name class is used to remove a name class from another. Note that this name class has no attributes.</para>
      </refsect1>
      <refsect1>
        <title>Restrictions:</title>
        <para>It is impossible to use <literal>except</literal> to produce empty name classes by including &quot;anyName&quot; in an &quot;except&quot; name class or &quot;nsName&quot; in an &quot;except&quot; name class included in another &quot;nsName&quot;.</para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
      &lt;element&gt;
        &lt;anyName&gt;
          &lt;except&gt;
            &lt;nsName ns=&quot;&quot;/&gt;
            &lt;nsName ns=&quot;http://eric.van-der-vlist.com/ns/library&quot;/&gt;
            &lt;nsName ns=&quot;http://eric.van-der-vlist.com/ns/person&quot;/&gt;
          &lt;/except&gt;
        &lt;/anyName&gt;
        &lt;ref name=&quot;anything&quot;/&gt;
      &lt;/element&gt;

      &lt;element&gt;
       &lt;nsName ns=ns=&quot;http://eric.van-der-vlist.com/ns/person&quot;/&gt;
         &lt;except&gt;
           &lt;name&gt;lib:name&lt;/name&gt;
           &lt;name&gt;hr:name&lt;/name&gt;
         &lt;except&gt;
       &lt;/nsName&gt;
       &lt;ref name=&quot;anything&quot;/&gt;
      &lt;/element&gt;

      </programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <para>None.</para>
      </refsect1>
    </refentry><refentry id="ch15-except1">
      <refmeta>
        <refentrytitle>except (in the context of a pattern)</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2605941">
          <primary>except (in the context of a pattern)</primary>
        </indexterm>
        <refname>except (in the context of a pattern)</refname>
        <refpurpose>Remove a set of values from a <literal>data</literal></refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>pattern</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element except
{
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   (
      ( element * - rng:* { ... }* )
    &amp; (
         element element { ... }
       | element attribute { ... }
       | element group { ... }
       | element interleave { ... }
       | element choice { ... }
       | element optional { ... }
       | element zeroOrMore { ... }
       | element oneOrMore { ... }
       | element list { ... }
       | element mixed { ... }
       | element ref { ... }
       | element parentRef { ... }
       | element empty { ... }
       | element text { ... }
       | element value { ... }
       | element data { ... }
       | element notAllowed { ... }
       | element externalRef { ... }
       | element grammar { ... }
      )+
   )
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>data</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>-pattern</para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>except</literal> pattern is used to remove a set of values from a <literal>data</literal> pattern.</para>
      </refsect1>
      <refsect1>
        <title>Restrictions:</title>
        <para>The <literal>except</literal> pattern can only be used in the context of data and can only contain <literal>data</literal>, <literal>value</literal> and <literal>choice</literal> elements.</para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
      &lt;element name=&quot;isbn&quot;&gt;
     &lt;data type=&quot;token&quot;&gt;
      &lt;except&gt;
       &lt;value&gt;0836217462&lt;/value&gt;
      &lt;/except&gt;
     &lt;/data&gt;
    &lt;/element&gt;

    &lt;attribute name=&quot;available&quot;&gt;
     &lt;data type=&quot;token&quot;&gt;
      &lt;except&gt;
       &lt;choice&gt;
        &lt;value type=&quot;string&quot;&gt;true&lt;/value&gt;
        &lt;value type=&quot;string&quot;&gt;false&lt;/value&gt;
       &lt;/choice&gt;
      &lt;/except&gt;
     &lt;/data&gt;
    &lt;/attribute&gt;

      </programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
        <varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The <literal>ns</literal> attribute defines the default namespace for the elements defined in a portion of schema. The value of <literal>ns</literal> is inherited.</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry><refentry id="ch15-externalRef">
      <refmeta>
        <refentrytitle>externalRef</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2605981">
          <primary>externalRef</primary>
        </indexterm>
        <refname>externalRef</refname>
        <refpurpose>Reference to an external schema</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>pattern</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element externalRef
{
   attribute href { xsd:anyURI },
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   ( element * - rng:* { ... }* )
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>attribute</literal>, <literal>choice</literal>, <literal>define</literal>, <literal>element</literal>, <literal>except</literal>, <literal>group</literal>, <literal>interleave</literal>, <literal>list</literal>, <literal>mixed</literal>, <literal>oneOrMore</literal>, <literal>optional</literal>, <literal>start</literal>, <literal>zeroOrMore</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>external</para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>externalRef</literal> pattern is a reference to an external schema. This has the same effect than replacing the <literal>externalRef</literal> pattern by the external schema considered as a pattern.</para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
      &lt;element name=&quot;book&quot;&gt;
        &lt;externalRef href=&quot;book.rng&quot;/&gt;
      &lt;/element&gt;
      
      &lt;element xmlns=&quot;http://relaxng.org/ns/structure/1.0&quot; name=&quot;university&quot;&gt;
       &lt;element name=&quot;name&quot;&gt;
        &lt;text/&gt;
       &lt;/element&gt;
       &lt;externalRef href=&quot;flat.rng&quot;/&gt;
      &lt;/element&gt;

      </programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
          
        <varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>href</literal>
            </term>
            <listitem>
              <para>The <literal>href</literal> attribute defines the location of the external schema.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The <literal>ns</literal> attribute defines the default namespace for the elements defined in a portion of schema. The value of <literal>ns</literal> is inherited.</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry><refentry id="ch15-grammar">
      <refmeta>
        <refentrytitle>grammar</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2605339">
          <primary>grammar</primary>
        </indexterm>
        <refname>grammar</refname>
        <refpurpose>Grammar pattern</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>pattern</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element grammar
{
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   (
      ( element * - rng:* { ... }* )
    &amp; (
         ( element start { ... } )
       | ( element define { ... } )
       | element div { ... }
       | element include { ... }
      )*
   )
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>attribute</literal>, <literal>choice</literal>, <literal>define</literal>, <literal>element</literal>, <literal>except</literal>, <literal>group</literal>, <literal>interleave</literal>, <literal>list</literal>, <literal>mixed</literal>, <literal>oneOrMore</literal>, <literal>optional</literal>, <literal>start</literal>, <literal>zeroOrMore</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>grammar</para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>grammar</literal> pattern encapsulates the definitions of <literal>start</literal> and named patterns.</para>
        <para>The most common use of <literal>grammar</literal> is to validate XML documents and in this case the <literal>start</literal> pattern defines which elements may be used as the document root element. The <literal>grammar</literal> pattern may also be used as a way to write modular schemas and in this case the <literal>start</literal> pattern defines which nodes must be matched by the <literal>grammar</literal> at the location where it appears in the schema.</para>
        <para>In every case, the named patterns defined in a <literal>grammar</literal> are considered to be local to this <literal>grammar</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
 &lt;grammar xmlns=&quot;http://relaxng.org/ns/structure/1.0&quot;&gt;
  &lt;start&gt;
   &lt;element name=&quot;library&quot;&gt;
    &lt;oneOrMore&gt;
     &lt;ref name=&quot;book-element&quot;/&gt;
    &lt;/oneOrMore&gt;
   &lt;/element&gt;
  &lt;/start&gt;
  &lt;define name=&quot;author-element&quot;&gt;
  .../...
  &lt;/define&gt;
 &lt;/grammar&gt;

  &lt;define name=&quot;author-element&quot;&gt;
    &lt;grammar&gt;
      &lt;start&gt;
        &lt;element name=&quot;author&quot;&gt;
          &lt;attribute name=&quot;id&quot;/&gt;
          &lt;ref name=&quot;name-element&quot;/&gt;
          &lt;parentRef name=&quot;born-element&quot;/&gt;
          &lt;optional&gt;
            &lt;ref name=&quot;died-element&quot;/&gt;
          &lt;/optional&gt;
        &lt;/element&gt;
      &lt;/start&gt;
      &lt;define name=&quot;name-element&quot;&gt;
        &lt;element name=&quot;name&quot;&gt;
          &lt;text/&gt;
        &lt;/element&gt;
      &lt;/define&gt;
      &lt;define name=&quot;died-element&quot;&gt;
        &lt;element name=&quot;died&quot;&gt;
          &lt;text/&gt;
        &lt;/element&gt;
      &lt;/define&gt;
    &lt;/grammar&gt;
  &lt;/define&gt;

  &lt;element xmlns=&quot;http://relaxng.org/ns/structure/1.0&quot; name=&quot;university&quot;&gt;
   &lt;element name=&quot;name&quot;&gt;
     &lt;text/&gt;
   &lt;/element&gt;
   &lt;grammar&gt;
     &lt;include href=&quot;flat.rng&quot;/&gt;
   &lt;/grammar&gt;
 &lt;/element&gt;

      </programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
        <varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The <literal>ns</literal> attribute defines the default namespace for the elements defined in a portion of schema. The value of <literal>ns</literal> is inherited.</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry><refentry id="ch15-group">
      <refmeta>
        <refentrytitle>group</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2605603">
          <primary>group</primary>
        </indexterm>
        <refname>group</refname>
        <refpurpose><literal>group</literal> pattern</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>pattern</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element group
{
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   (
      ( element * - rng:* { ... }* )
    &amp; (
         element element { ... }
       | element attribute { ... }
       | element group { ... }
       | element interleave { ... }
       | element choice { ... }
       | element optional { ... }
       | element zeroOrMore { ... }
       | element oneOrMore { ... }
       | element list { ... }
       | element mixed { ... }
       | element ref { ... }
       | element parentRef { ... }
       | element empty { ... }
       | element text { ... }
       | element value { ... }
       | element data { ... }
       | element notAllowed { ... }
       | element externalRef { ... }
       | element grammar { ... }
      )+
   )
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>attribute</literal>, <literal>choice</literal>, <literal>define</literal>, <literal>element</literal>, <literal>except</literal>, <literal>group</literal>, <literal>interleave</literal>, <literal>list</literal>, <literal>mixed</literal>, <literal>oneOrMore</literal>, <literal>optional</literal>, <literal>start</literal>, <literal>zeroOrMore</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>pattern,pattern</para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>group</literal> pattern defines an ordered group of sub patterns (note that when <literal>attribute</literal> patterns are included in such a group, their order is not enforced). <literal>group</literal> patterns are implicit with <literal>element</literal> and <literal>define</literal> patterns.</para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
   &lt;element name=&quot;name&quot;&gt;
    &lt;choice&gt;
     &lt;text/&gt;
     &lt;group&gt;
      &lt;element name=&quot;first&quot;&gt;&lt;text/&gt;&lt;/element&gt;
      &lt;optional&gt;
        &lt;element name=&quot;middle&quot;&gt;&lt;text/&gt;&lt;/element&gt;
      &lt;/optional&gt;
      &lt;element name=&quot;last&quot;&gt;&lt;text/&gt;&lt;/element&gt;
     &lt;/group&gt;
    &lt;/choice&gt;
   &lt;/element&gt;

 &lt;element name=&quot;foo&quot;&gt;
  &lt;interleave&gt;
   &lt;element name=&quot;out&quot;&gt;&lt;empty/&gt;&lt;/element&gt;
   &lt;group&gt;
    &lt;element name=&quot;in1&quot;&gt;&lt;empty/&gt;&lt;/element&gt;
    &lt;element name=&quot;in2&quot;&gt;&lt;empty/&gt;&lt;/element&gt;
   &lt;/group&gt;
  &lt;/interleave&gt;
 &lt;/element&gt;
      </programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
        <varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The <literal>ns</literal> attribute defines the default namespace for the elements defined in a portion of schema. The value of <literal>ns</literal> is inherited.</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry><refentry id="ch15-include">
      <refmeta>
        <refentrytitle>include</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2605408">
          <primary>include</primary>
        </indexterm>
        <refname>include</refname>
        <refpurpose>Grammar merge</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>grammar-content</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element include
{
   attribute href { xsd:anyURI },
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   (
      ( element * - rng:* { ... }* )
    &amp; (
         ( element start { ... } )
       | ( element define { ... } )
       | element div { ... }
      )*
   )
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>div</literal>, <literal>grammar</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>include</para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>include</literal> pattern includes a grammar and merges its definitions with the definitions of the current grammar. The definitions of the included grammar may be redefined and overridden by the definitions embedded in the <literal>include</literal> pattern. Note that a schema must contain an explicit <literal>grammar</literal> definition in order to be included.</para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
  &lt;grammar xmlns=&quot;http://relaxng.org/ns/structure/1.0&quot;&gt;
   &lt;start&gt;
    &lt;element name=&quot;library&quot;&gt;
     &lt;oneOrMore&gt;
      &lt;ref name=&quot;book-element&quot;/&gt;
     &lt;/oneOrMore&gt;
    &lt;/element&gt;
   &lt;/start&gt;
   &lt;include href=&quot;included.rng&quot;/&gt;
   .../...
  &lt;/grammar&gt;

  &lt;grammar xmlns=&quot;http://relaxng.org/ns/structure/1.0&quot;&gt;
   &lt;include href=&quot;flat.rng&quot;&gt;
     &lt;define name=&quot;book-element&quot;&gt;
       &lt;element name=&quot;book&quot;&gt;
         &lt;attribute name=&quot;id&quot;/&gt;
         &lt;attribute name=&quot;available&quot;/&gt;
         &lt;ref name=&quot;isbn-element&quot;/&gt;
         &lt;ref name=&quot;title-element&quot;/&gt;
         &lt;ref name=&quot;description-element&quot;/&gt;
         &lt;zeroOrMore&gt;
           &lt;ref name=&quot;author-element&quot;/&gt;
         &lt;/zeroOrMore&gt;
       &lt;/element&gt;
     &lt;/define&gt;
   &lt;/include&gt;
   &lt;define name=&quot;description-element&quot;&gt;
     &lt;element name=&quot;description&quot;&gt;
       &lt;text/&gt;
     &lt;/element&gt;
   &lt;/define&gt;
 &lt;/grammar&gt;

      </programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
          
        <varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>href</literal>
            </term>
            <listitem>
              <para>The <literal>href</literal> attribute defines the location of the schema which grammar should be included.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The <literal>ns</literal> attribute defines the default namespace for the elements defined in a portion of schema. The value of <literal>ns</literal> is inherited.</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry><refentry id="ch15-interleave">
      <refmeta>
        <refentrytitle>interleave</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2605622">
          <primary>interleave</primary>
        </indexterm>
        <refname>interleave</refname>
        <refpurpose><literal>interleave</literal> Pattern</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>pattern</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element interleave
{
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   (
      ( element * - rng:* { ... }* )
    &amp; (
         element element { ... }
       | element attribute { ... }
       | element group { ... }
       | element interleave { ... }
       | element choice { ... }
       | element optional { ... }
       | element zeroOrMore { ... }
       | element oneOrMore { ... }
       | element list { ... }
       | element mixed { ... }
       | element ref { ... }
       | element parentRef { ... }
       | element empty { ... }
       | element text { ... }
       | element value { ... }
       | element data { ... }
       | element notAllowed { ... }
       | element externalRef { ... }
       | element grammar { ... }
      )+
   )
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>attribute</literal>, <literal>choice</literal>, <literal>define</literal>, <literal>element</literal>, <literal>except</literal>, <literal>group</literal>, <literal>interleave</literal>, <literal>list</literal>, <literal>mixed</literal>, <literal>oneOrMore</literal>, <literal>optional</literal>, <literal>start</literal>, <literal>zeroOrMore</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>pattern&amp;pattern</para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>interleave</literal> pattern &quot;interleaves&quot; sub patterns, i.e. allows their leaves to be mixed in any relative order.</para>
        <para><literal>interleave</literal> is more than defining unordered groups as we can see on the following example: consider element &quot;a&quot; and the ordered group of element &quot;b1&quot; and &quot;b2&quot;. An unordered group of these two patterns would only allow element &quot;a&quot; followed by elements &quot;b1&quot; and &quot;b2&quot; or elements &quot;b1&quot; and &quot;b2 followed by element &quot;a&quot;. An <literal>interleave</literal> of these two patterns does allow these two combinations but also element &quot;b1&quot; followed by &quot;a&quot; followed by &quot;b2&quot;, i.e. a combination where the element &quot;a&quot; has been &quot;interleaved&quot; between elements &quot;b1&quot; and &quot;b2&quot;.</para>
        <para>The <literal>interleave</literal> behavior is the behavior applied to <literal>attribute</literal> patterns even when they are embedded in (ordered) <literal>group</literal> patterns (the reason for this is that XML 1.0 specifies that the relative order of attributes is not significant).</para>
        <para>Another case where <literal>interleave</literal> patterns are often needed is to described mixed content models, i.e. content models where <literal>text</literal> are interleaved between elements. A shortcut (the <literal>mixed</literal> pattern) has been defined for this case.</para>
      </refsect1>
      <refsect1>
        <title>Restrictions:</title>
        <para>
          <itemizedList>
            <listItem>
              <para>The <literal>interleave</literal> pattern cannot be used within a <literal>list</literal>.</para>
            </listItem>
            <listItem>
              <para>Elements within a <literal>interleave</literal> pattern cannot have overlapping name classes.</para>
            </listItem>
            <listItem>
              <para>There must be at most one &quot;text&quot; pattern in each set of patterns combined by <literal>interleave</literal></para>
            </listItem>
          </itemizedList>
        </para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
     &lt;element name=&quot;character&quot;&gt;
      &lt;interleave&gt;
       &lt;attribute name=&quot;id&quot;/&gt;
       &lt;element name=&quot;name&quot;&gt;
        &lt;text/&gt;
       &lt;/element&gt;
       &lt;element name=&quot;born&quot;&gt;
        &lt;text/&gt;
       &lt;/element&gt;
       &lt;element name=&quot;qualification&quot;&gt;
        &lt;text/&gt;
       &lt;/element&gt;
      &lt;/interleave&gt;
     &lt;/element&gt;

    &lt;element name=&quot;title&quot;&gt;
     &lt;interleave&gt;
      &lt;attribute name=&quot;xml:lang&quot;/&gt;
      &lt;zeroOrMore&gt;
       &lt;element name=&quot;a&quot;&gt;
        &lt;attribute name=&quot;href&quot;/&gt;
        &lt;text/&gt;
       &lt;/element&gt;
      &lt;/zeroOrMore&gt;
      &lt;text/&gt;
     &lt;/interleave&gt;
    &lt;/element&gt;
			</programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
        <varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The <literal>ns</literal> attribute defines the default namespace for the elements defined in a portion of schema. The value of <literal>ns</literal> is inherited.</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry><refentry id="ch15-list">
      <refmeta>
        <refentrytitle>list</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2605710">
          <primary>list</primary>
        </indexterm>
        <refname>list</refname>
        <refpurpose>Text node split</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>pattern</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element list
{
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   (
      ( element * - rng:* { ... }* )
    &amp; (
         element element { ... }
       | element attribute { ... }
       | element group { ... }
       | element interleave { ... }
       | element choice { ... }
       | element optional { ... }
       | element zeroOrMore { ... }
       | element oneOrMore { ... }
       | element list { ... }
       | element mixed { ... }
       | element ref { ... }
       | element parentRef { ... }
       | element empty { ... }
       | element text { ... }
       | element value { ... }
       | element data { ... }
       | element notAllowed { ... }
       | element externalRef { ... }
       | element grammar { ... }
      )+
   )
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>attribute</literal>, <literal>choice</literal>, <literal>define</literal>, <literal>element</literal>, <literal>except</literal>, <literal>group</literal>, <literal>interleave</literal>, <literal>list</literal>, <literal>mixed</literal>, <literal>oneOrMore</literal>, <literal>optional</literal>, <literal>start</literal>, <literal>zeroOrMore</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>list</para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>list</literal> pattern splits a text node into tokens separated by white spaces to allow the validation of these tokens separately. This is most useful for validating lists of values.</para>
      </refsect1>
      <refsect1>
        <title>Restrictions:</title>
        <para>
          <itemizedList>
            <listItem>
              <para><literal>interleave</literal> cannot be used within <literal>list</literal>.</para>
            </listItem>
            <listItem>
              <para>The content of a <literal>list</literal> is only about data: it's forbidden to define <literal>element</literal>, <literal>attribute</literal> or <literal>text</literal> there.</para>
            </listItem>
            <listItem>
              <para>It's forbidden to embed <literal>list</literal> into <literal>list</literal>.</para>
            </listItem>
          </itemizedList>
        </para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
    &lt;attribute name=&quot;see-also&quot;&gt;
     &lt;list&gt;
      &lt;zeroOrMore&gt;
       &lt;data type=&quot;token&quot;/&gt;
      &lt;/zeroOrMore&gt;
     &lt;/list&gt;
    &lt;/attribute&gt;

    &lt;attribute name=&quot;dimensions&quot;&gt;
     &lt;list&gt;
      &lt;data type=&quot;xs:decimal&quot;/&gt;
      &lt;data type=&quot;xs:decimal&quot;/&gt;
      &lt;data type=&quot;xs:decimal&quot;/&gt;
      &lt;choice&gt;
       &lt;value&gt;inches&lt;/value&gt;
       &lt;value&gt;cm&lt;/value&gt;
       &lt;value&gt;mm&lt;/value&gt;
      &lt;/choice&gt;
     &lt;/list&gt;
    &lt;/attribute&gt;
			</programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
        <varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The <literal>ns</literal> attribute defines the default namespace for the elements defined in a portion of schema. The value of <literal>ns</literal> is inherited.</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry><refentry id="ch15-mixed">
      <refmeta>
        <refentrytitle>mixed</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2605728">
          <primary>mixed</primary>
        </indexterm>
        <refname>mixed</refname>
        <refpurpose>Pattern for mixed content models</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>pattern</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element mixed
{
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   (
      ( element * - rng:* { ... }* )
    &amp; (
         element element { ... }
       | element attribute { ... }
       | element group { ... }
       | element interleave { ... }
       | element choice { ... }
       | element optional { ... }
       | element zeroOrMore { ... }
       | element oneOrMore { ... }
       | element list { ... }
       | element mixed { ... }
       | element ref { ... }
       | element parentRef { ... }
       | element empty { ... }
       | element text { ... }
       | element value { ... }
       | element data { ... }
       | element notAllowed { ... }
       | element externalRef { ... }
       | element grammar { ... }
      )+
   )
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>attribute</literal>, <literal>choice</literal>, <literal>define</literal>, <literal>element</literal>, <literal>except</literal>, <literal>group</literal>, <literal>interleave</literal>, <literal>list</literal>, <literal>mixed</literal>, <literal>oneOrMore</literal>, <literal>optional</literal>, <literal>start</literal>, <literal>zeroOrMore</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>mixed</para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>mixed</literal> pattern is a shortcut for <literal>interleave</literal> with an embedded <literal>text</literal> pattern. It describes unordered content models where a text node may be included before and after each element. Note that Relax NG does not allow to add constraints on these text nodes.</para>
      </refsect1>
      <refsect1>
        <title>Restrictions:</title>
        <para>The limitations of <literal>interleave</literal> apply here:</para>
        <itemizedList>
          <listItem>
            <para>The <literal>mixed</literal> pattern cannot be used within a <literal>list</literal>.</para>
          </listItem>
          <listItem>
            <para>Elements within a <literal>mixed</literal> pattern cannot have overlapping name classes.</para>
          </listItem>
          <listItem>
            <para>There must no other &quot;text&quot; pattern in each set of patterns combined by <literal>mixed</literal></para>
          </listItem>
        </itemizedList>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
    &lt;element name=&quot;title&quot;&gt;
     &lt;mixed&gt;
      &lt;attribute name=&quot;xml:lang&quot;/&gt;
      &lt;zeroOrMore&gt;
       &lt;element name=&quot;a&quot;&gt;
        &lt;attribute name=&quot;href&quot;/&gt;
        &lt;text/&gt;
       &lt;/element&gt;
      &lt;/zeroOrMore&gt;
     &lt;/mixed&gt;
    &lt;/element&gt;
 
is equivalent to:
 
    &lt;element name=&quot;title&quot;&gt;
     &lt;interleave&gt;
      &lt;text/&gt;
      &lt;group&gt;
        &lt;attribute name=&quot;xml:lang&quot;/&gt;
        &lt;zeroOrMore&gt;
         &lt;element name=&quot;a&quot;&gt;
          &lt;attribute name=&quot;href&quot;/&gt;
          &lt;text/&gt;
        &lt;/element&gt;
        &lt;/zeroOrMore&gt;
      &lt;/group&gt;
     &lt;/interleave&gt;
    &lt;/element&gt;
 
which itself is equivalent to:

    &lt;element name=&quot;title&quot;&gt;
     &lt;interleave&gt;
      &lt;text/&gt;
      &lt;attribute name=&quot;xml:lang&quot;/&gt;
      &lt;zeroOrMore&gt;
       &lt;element name=&quot;a&quot;&gt;
        &lt;attribute name=&quot;href&quot;/&gt;
        &lt;text/&gt;
      &lt;/element&gt;
      &lt;/zeroOrMore&gt;
     &lt;/interleave&gt;
    &lt;/element&gt;


			</programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
        <varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The <literal>ns</literal> attribute defines the default namespace for the elements defined in a portion of schema. The value of <literal>ns</literal> is inherited.</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry><refentry id="ch15-name">
      <refmeta>
        <refentrytitle>name</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2606479">
          <primary>name</primary>
        </indexterm>
        <refname>name</refname>
        <refpurpose>Name class for a single name</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>name-class</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element name
{
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   xsd:QName
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>attribute</literal>, <literal>choice</literal>, <literal>element</literal>, <literal>except</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>name</para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>name</literal> name class defines a class with a single name.</para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
 &lt;element&gt;
   &lt;nsName ns=&quot;http://eric.van-der-vlist.com/ns/person&quot;/&gt;
     &lt;except&gt;
       &lt;name&gt;lib:name&lt;/name&gt;
       &lt;name&gt;hr:name&lt;/name&gt;
     &lt;except&gt;
   &lt;/nsName&gt;
   &lt;ref name=&quot;anything&quot;/&gt;
 &lt;/element&gt;

 &lt;element&gt;
   &lt;choice&gt;
     &lt;name&gt;lib:name&lt;/name&gt;
     &lt;name&gt;hr:name&lt;/name&gt;
   &lt;/choice&gt;
   &lt;ref name=&quot;name-content&quot;/&gt;
 &lt;/element&gt;

			</programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
        <varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The <literal>ns</literal> attribute defines the default namespace for the elements defined in a portion of schema. The value of <literal>ns</literal> is inherited.</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry><refentry id="ch15-notAllowed">
      <refmeta>
        <refentrytitle>notAllowed</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2605963">
          <primary>notAllowed</primary>
        </indexterm>
        <refname>notAllowed</refname>
        <refpurpose>Not allowed</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>pattern</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element notAllowed
{
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   ( element * - rng:* { ... }* )
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>attribute</literal>, <literal>choice</literal>, <literal>define</literal>, <literal>element</literal>, <literal>except</literal>, <literal>group</literal>, <literal>interleave</literal>, <literal>list</literal>, <literal>mixed</literal>, <literal>oneOrMore</literal>, <literal>optional</literal>, <literal>start</literal>, <literal>zeroOrMore</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>notAllowed</para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>notAllowed</literal> pattern always fails. It can be used to provide abstract definitions which must be overridden before they can be used in a schema.</para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
  &lt;define name=&quot;isbn-element&quot; combine=&quot;choice&quot;&gt;
    &lt;notAllowed/&gt;
  &lt;/define&gt;
	</programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
        <varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The <literal>ns</literal> attribute defines the default namespace for the elements defined in a portion of schema. The value of <literal>ns</literal> is inherited.</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry><refentry id="ch15-nsName">
      <refmeta>
        <refentrytitle>nsName</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2606515">
          <primary>nsName</primary>
        </indexterm>
        <refname>nsName</refname>
        <refpurpose>Name class for any name in a namespace</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>name-class</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element nsName
{
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   ( ( element * - rng:* { ... }* ) &amp; element except { ... }? )
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>attribute</literal>, <literal>choice</literal>, <literal>element</literal>, <literal>except</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>nsName exceptNameClass</para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>nsName</literal> name class allows any name in a specific namespace.</para>
      </refsect1>
      <refsect1>
        <title>Restrictions:</title>
        <para>Within the scope of an element, the name classes of attributes cannot overlap. The same restriction applies to name classes of elements when these elements are combined by <literal>interleave</literal>. It is impossible to use <literal>nsName</literal> to produce empty name classes by including <literal>nsName</literal> in an <literal>except</literal> name class included in another <literal>nsName</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
 &lt;element&gt;
   &lt;choice&gt;
     &lt;nsName ns=&quot;http://eric.van-der-vlist.com/ns/library&quot;/&gt;
     &lt;nsName ns=&quot;http://eric.van-der-vlist.com/ns/person&quot;/&gt;
   &lt;/choice&gt;
   &lt;ref name=&quot;anything&quot;/&gt;
 &lt;/element&gt;

 &lt;element&gt;
   &lt;nsName ns=&quot;http://eric.van-der-vlist.com/ns/person&quot;/&gt;
     &lt;except&gt;
       &lt;name&gt;lib:name&lt;/name&gt;
       &lt;name&gt;hr:name&lt;/name&gt;
     &lt;except&gt;
   &lt;/nsName&gt;
   &lt;ref name=&quot;anything&quot;/&gt;
 &lt;/element&gt;

			</programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
        <varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The <literal>ns</literal> attribute defines the default namespace for the elements defined in a portion of schema. The value of <literal>ns</literal> is inherited.</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry><refentry id="ch15-oneOrMore">
      <refmeta>
        <refentrytitle>oneOrMore</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2605692">
          <primary>oneOrMore</primary>
        </indexterm>
        <refname>oneOrMore</refname>
        <refpurpose><literal>oneOrMore</literal> pattern</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>pattern</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element oneOrMore
{
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   (
      ( element * - rng:* { ... }* )
    &amp; (
         element element { ... }
       | element attribute { ... }
       | element group { ... }
       | element interleave { ... }
       | element choice { ... }
       | element optional { ... }
       | element zeroOrMore { ... }
       | element oneOrMore { ... }
       | element list { ... }
       | element mixed { ... }
       | element ref { ... }
       | element parentRef { ... }
       | element empty { ... }
       | element text { ... }
       | element value { ... }
       | element data { ... }
       | element notAllowed { ... }
       | element externalRef { ... }
       | element grammar { ... }
      )+
   )
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>attribute</literal>, <literal>choice</literal>, <literal>define</literal>, <literal>element</literal>, <literal>except</literal>, <literal>group</literal>, <literal>interleave</literal>, <literal>list</literal>, <literal>mixed</literal>, <literal>oneOrMore</literal>, <literal>optional</literal>, <literal>start</literal>, <literal>zeroOrMore</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>
          <literal>pattern+</literal>
        </para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>oneOrMore</literal> pattern specifies that its sub patterns considered as an ordered group must be matched one or more time.</para>
      </refsect1>
      <refsect1>
        <title>Restrictions:</title>
        <para>The <literal>oneOrMore</literal> pattern cannot contain attribute definitions.</para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
 &lt;element name=&quot;library&quot;&gt;
  &lt;oneOrMore&gt;
   &lt;element name=&quot;book&quot;&gt;
   .../...
   &lt;/element&gt;
  &lt;/oneOrMore&gt;
 &lt;/element&gt;			</programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
        <varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The <literal>ns</literal> attribute defines the default namespace for the elements defined in a portion of schema. The value of <literal>ns</literal> is inherited.</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry><refentry id="ch15-optional">
      <refmeta>
        <refentrytitle>optional</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2605657">
          <primary>optional</primary>
        </indexterm>
        <refname>optional</refname>
        <refpurpose><literal>optional</literal> pattern</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>pattern</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element optional
{
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   (
      ( element * - rng:* { ... }* )
    &amp; (
         element element { ... }
       | element attribute { ... }
       | element group { ... }
       | element interleave { ... }
       | element choice { ... }
       | element optional { ... }
       | element zeroOrMore { ... }
       | element oneOrMore { ... }
       | element list { ... }
       | element mixed { ... }
       | element ref { ... }
       | element parentRef { ... }
       | element empty { ... }
       | element text { ... }
       | element value { ... }
       | element data { ... }
       | element notAllowed { ... }
       | element externalRef { ... }
       | element grammar { ... }
      )+
   )
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>attribute</literal>, <literal>choice</literal>, <literal>define</literal>, <literal>element</literal>, <literal>except</literal>, <literal>group</literal>, <literal>interleave</literal>, <literal>list</literal>, <literal>mixed</literal>, <literal>oneOrMore</literal>, <literal>optional</literal>, <literal>start</literal>, <literal>zeroOrMore</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>
          <literal>pattern?</literal>
        </para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>optional</literal> pattern specifies that its sub-patterns considered as an ordered group is optional, i.e. must be matched zero or one time.</para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
     &lt;element name=&quot;author&quot;&gt;
      &lt;attribute name=&quot;id&quot;/&gt;
      &lt;element name=&quot;name&quot;&gt;
       &lt;text/&gt;
      &lt;/element&gt;
      &lt;element name=&quot;born&quot;&gt;
       &lt;text/&gt;
      &lt;/element&gt;
      &lt;optional&gt;
       &lt;element name=&quot;died&quot;&gt;
        &lt;text/&gt;
       &lt;/element&gt;
      &lt;/optional&gt;
     &lt;/element&gt;
		 
   &lt;element name=&quot;name&quot;&gt;
    &lt;choice&gt;
     &lt;text/&gt;
     &lt;group&gt;
      &lt;element name=&quot;first&quot;&gt;&lt;text/&gt;&lt;/element&gt;
      &lt;optional&gt;
        &lt;element name=&quot;middle&quot;&gt;&lt;text/&gt;&lt;/element&gt;
      &lt;/optional&gt;
      &lt;element name=&quot;last&quot;&gt;&lt;text/&gt;&lt;/element&gt;
     &lt;/group&gt;
    &lt;/choice&gt;
   &lt;/element&gt;

			</programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
        <varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The <literal>ns</literal> attribute defines the default namespace for the elements defined in a portion of schema. The value of <literal>ns</literal> is inherited.</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry><refentry id="ch15-param">
      <refmeta>
        <refentrytitle>param</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2605909">
          <primary>param</primary>
        </indexterm>
        <refname>param</refname>
        <refpurpose>Datatype parameter</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>pattern</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element param
{
   attribute name { xsd:NCName },
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   text
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>data</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>param</para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>param</literal> element defines parameters passed to the datatype library to determine if a value is valid per a datatype. When the datatype library is the W3C XML Schema datatypes, these parameters are the facets of the datatype and they define additional restrictions to be applied. The name of the parameter is defined by the <literal>name</literal> attribute and its value is the content of the <literal>param</literal> element.</para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
   &lt;element name=&quot;book&quot;&gt;
    &lt;attribute name=&quot;id&quot;&gt;
     &lt;data type=&quot;NMTOKEN&quot;&gt;
       &lt;param name=&quot;maxLength&quot;&gt;16&lt;/param&gt;
     &lt;/data&gt;
    &lt;/attribute&gt;
    &lt;attribute name=&quot;available&quot;&gt;
     &lt;data type=&quot;boolean&quot;/&gt;
    &lt;/attribute&gt;
    &lt;element name=&quot;isbn&quot;&gt;
     &lt;data type=&quot;NMTOKEN&quot;&gt;
       &lt;param name=&quot;pattern&quot;&gt;[0-9]{9}[0-9x]&lt;/param&gt;
     &lt;/data&gt;
    &lt;/element&gt;
    &lt;element name=&quot;title&quot;&gt;
     &lt;attribute name=&quot;xml:lang&quot;&gt;
      &lt;data type=&quot;language&quot;&gt;
       &lt;param name=&quot;length&quot;&gt;2&lt;/param&gt;
      &lt;/data&gt;
     &lt;/attribute&gt;
     &lt;data type=&quot;token&quot;&gt;
       &lt;param name=&quot;maxLength&quot;&gt;255&lt;/param&gt;
     &lt;/data&gt;
    &lt;/element&gt;
		</programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
          
        <varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>name</literal>
            </term>
            <listitem>
              <para>The <literal>name</literal> attribute specifies the name of the parameter.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The <literal>ns</literal> attribute defines the default namespace for the elements defined in a portion of schema. The value of <literal>ns</literal> is inherited.</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry><refentry id="ch15-parentRef">
      <refmeta>
        <refentrytitle>parentRef</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2605775">
          <primary>parentRef</primary>
        </indexterm>
        <refname>parentRef</refname>
        <refpurpose>Reference to a named pattern from the parent grammar</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>pattern</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element parentRef
{
   attribute name { xsd:NCName },
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   ( element * - rng:* { ... }* )
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>attribute</literal>, <literal>choice</literal>, <literal>define</literal>, <literal>element</literal>, <literal>except</literal>, <literal>group</literal>, <literal>interleave</literal>, <literal>list</literal>, <literal>mixed</literal>, <literal>oneOrMore</literal>, <literal>optional</literal>, <literal>start</literal>, <literal>zeroOrMore</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>parent</para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>parentRef</literal> pattern is a reference to a named pattern belonging to the parent <literal>grammar</literal>, i.e. the <literal>grammar</literal> in which the current <literal>grammar</literal> is included. The scope of named pattern is usually limited to the <literal>grammar</literal> in which they are defined and the <literal>parentRef</literal> pattern provides a way to extend this scope and refer named pattern defined in the parent <literal>grammar</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
  &lt;define name=&quot;born-element&quot;&gt;
    &lt;element name=&quot;born&quot;&gt;
      &lt;text/&gt;
    &lt;/element&gt;
  &lt;/define&gt;
  &lt;define name=&quot;author-element&quot;&gt;
    &lt;grammar&gt;
      &lt;start&gt;
        &lt;element name=&quot;author&quot;&gt;
          &lt;attribute name=&quot;id&quot;/&gt;
          &lt;ref name=&quot;name-element&quot;/&gt;
          &lt;parentRef name=&quot;born-element&quot;/&gt;
          &lt;optional&gt;
            &lt;ref name=&quot;died-element&quot;/&gt;
          &lt;/optional&gt;
        &lt;/element&gt;
      &lt;/start&gt;
      &lt;define name=&quot;name-element&quot;&gt;
        &lt;element name=&quot;name&quot;&gt;
          &lt;text/&gt;
        &lt;/element&gt;
      &lt;/define&gt;
      &lt;define name=&quot;died-element&quot;&gt;
        &lt;element name=&quot;died&quot;&gt;
          &lt;text/&gt;
        &lt;/element&gt;
      &lt;/define&gt;
    &lt;/grammar&gt;
  &lt;/define&gt;			
			</programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
          
        <varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>name</literal>
            </term>
            <listitem>
              <para>The <literal>name</literal> attribute specifies the name of the named pattern which is referenced.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The <literal>ns</literal> attribute defines the default namespace for the elements defined in a portion of schema. The value of <literal>ns</literal> is inherited.</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry><refentry id="ch15-ref">
      <refmeta>
        <refentrytitle>ref</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2605745">
          <primary>ref</primary>
        </indexterm>
        <refname>ref</refname>
        <refpurpose>Reference to a named pattern</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>pattern</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element ref
{
   attribute name { xsd:NCName },
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   ( element * - rng:* { ... }* )
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>attribute</literal>, <literal>choice</literal>, <literal>define</literal>, <literal>element</literal>, <literal>except</literal>, <literal>group</literal>, <literal>interleave</literal>, <literal>list</literal>, <literal>mixed</literal>, <literal>oneOrMore</literal>, <literal>optional</literal>, <literal>start</literal>, <literal>zeroOrMore</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>Name without a colon</para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>ref</literal> pattern defines a reference to a named pattern defined in the current <literal>grammar</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
 &lt;element name=&quot;book&quot;&gt;
  &lt;ref name=&quot;book-start&quot;/&gt;
  &lt;ref name=&quot;book-end&quot;/&gt;
 &lt;/element&gt;
 
   &lt;element name=&quot;library&quot;&gt;
    &lt;oneOrMore&gt;
     &lt;ref name=&quot;book-element&quot;/&gt;
    &lt;/oneOrMore&gt;
   &lt;/element&gt;
 
 </programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
          
        <varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>name</literal>
            </term>
            <listitem>
              <para>The <literal>name</literal> attribute specifies the name of the named pattern which is referenced.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The <literal>ns</literal> attribute defines the default namespace for the elements defined in a portion of schema. The value of <literal>ns</literal> is inherited.</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry><refentry id="ch15-start">
      <refmeta>
        <refentrytitle>start</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2606326">
          <primary>start</primary>
        </indexterm>
        <refname>start</refname>
        <refpurpose>Start of a grammar</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>start-element</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element start
{
   ( attribute combine { &quot;choice&quot; | &quot;interleave&quot; }? ),
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   (
      ( element * - rng:* { ... }* )
    &amp; (
         element element { ... }
       | element attribute { ... }
       | element group { ... }
       | element interleave { ... }
       | element choice { ... }
       | element optional { ... }
       | element zeroOrMore { ... }
       | element oneOrMore { ... }
       | element list { ... }
       | element mixed { ... }
       | element ref { ... }
       | element parentRef { ... }
       | element empty { ... }
       | element text { ... }
       | element value { ... }
       | element data { ... }
       | element notAllowed { ... }
       | element externalRef { ... }
       | element grammar { ... }
      )
   )
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>div</literal>, <literal>grammar</literal>, <literal>include</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>start</para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>start</literal> pattern defines the &quot;start&quot; of a <literal>grammar</literal>. When this grammar is used to validate a complete document, the <literal>start</literal> pattern defines which elements may be used as the document (root) element. When this grammar is embedded in another <literal>grammar</literal>, the <literal>start</literal> pattern describes which pattern should be applied at the location where the <literal>grammar</literal> is embedded. Like named pattern definitions, start patterns may be combined by <literal>choice</literal> or <literal>interleave</literal> and redefined when they are included in <literal>include</literal> patterns.</para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
  &lt;start&gt;
   &lt;element name=&quot;library&quot;&gt;
    &lt;oneOrMore&gt;
     &lt;ref name=&quot;book-element&quot;/&gt;
    &lt;/oneOrMore&gt;
   &lt;/element&gt;
  &lt;/start&gt;
  &lt;start combine=&quot;choice&quot;&gt;
    &lt;ref name=&quot;book-element&quot;/&gt;
  &lt;/start&gt;

  &lt;define name=&quot;author-element&quot;&gt;
    &lt;grammar&gt;
      &lt;start&gt;
        &lt;element name=&quot;author&quot;&gt;
          &lt;attribute name=&quot;id&quot;/&gt;
          &lt;ref name=&quot;name-element&quot;/&gt;
          &lt;ref name=&quot;born-element&quot;/&gt;
          &lt;optional&gt;
            &lt;ref name=&quot;died-element&quot;/&gt;
          &lt;/optional&gt;
        &lt;/element&gt;
      &lt;/start&gt;
      &lt;define name=&quot;name-element&quot;&gt;
        &lt;element name=&quot;name&quot;&gt;
          &lt;text/&gt;
        &lt;/element&gt;
      &lt;/define&gt;
      &lt;define name=&quot;born-element&quot;&gt;
        &lt;element name=&quot;born&quot;&gt;
          &lt;text/&gt;
        &lt;/element&gt;
      &lt;/define&gt;
      &lt;define name=&quot;died-element&quot;&gt;
        &lt;element name=&quot;died&quot;&gt;
          &lt;text/&gt;
        &lt;/element&gt;
      &lt;/define&gt;
    &lt;/grammar&gt;
  &lt;/define&gt;


			</programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
          
        <varlistentry>
            <term>
              <literal>combine</literal>
            </term>
            <listitem>
              <para>The <literal>combine</literal> attribute specifies how multiple definitions of <literal>start</literal> pattern should be combined together. The possible values are <literal>choice</literal> and <literal>interleave</literal>.</para>
              <para>When the <literal>combine</literal> attribute is specified and set to <literal>choice</literal>, multiple definitions of a  <literal>start</literal> pattern are combined in a <literal>choice</literal> pattern. When the <literal>combine</literal> attribute is specified and set to <literal>interleave</literal>, multiple definitions of a  <literal>start</literal> pattern are combined in an <literal>interleave</literal> pattern.</para>
              <para>Note that it is forbidden to specify more than one <literal>start</literal> with the same name and no <literal>combine</literal> attribute or multiple <literal>start</literal> with different values of <literal>combine</literal> attribute.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The <literal>ns</literal> attribute defines the default namespace for the elements defined in a portion of schema. The value of <literal>ns</literal> is inherited.</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry><refentry id="ch15-text">
      <refmeta>
        <refentrytitle>text</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2605822">
          <primary>text</primary>
        </indexterm>
        <refname>text</refname>
        <refpurpose>Pattern matching text nodes</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>pattern</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element text
{
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   ( element * - rng:* { ... }* )
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>attribute</literal>, <literal>choice</literal>, <literal>define</literal>, <literal>element</literal>, <literal>except</literal>, <literal>group</literal>, <literal>interleave</literal>, <literal>list</literal>, <literal>mixed</literal>, <literal>oneOrMore</literal>, <literal>optional</literal>, <literal>start</literal>, <literal>zeroOrMore</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>text</para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>text</literal> pattern matches zero or more text nodes. The fact that a <literal>text</literal> pattern matches more than one text node has no effect when it is used in ordered content models (the data model used by Relax NG for XML documents is similar to the data model of XPath 1.0 and two text nodes cannot be adjacent) but makes a difference when a <literal>text</literal> pattern is used in <literal>interleave</literal>:adding a single <literal>text</literal> pattern in an <literal>interleave</literal> pattern has the effect of allowing any number of text nodes which can interleave before and after each element (note that the <literal>mixed</literal> pattern is provided as a shortcut to define these content models).</para>
      </refsect1>
      <refsect1>
        <title>Restrictions:</title>
        <para>No more than one <literal>text</literal> pattern can be included in an <literal>interleave</literal> pattern. </para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
  &lt;element name=&quot;first&quot;&gt;&lt;text/&gt;&lt;/element&gt;

   &lt;element name=&quot;name&quot;&gt;
    &lt;choice&gt;
     &lt;text/&gt;
     &lt;group&gt;
      &lt;element name=&quot;first&quot;&gt;&lt;text/&gt;&lt;/element&gt;
      &lt;optional&gt;
        &lt;element name=&quot;middle&quot;&gt;&lt;text/&gt;&lt;/element&gt;
      &lt;/optional&gt;
      &lt;element name=&quot;last&quot;&gt;&lt;text/&gt;&lt;/element&gt;
     &lt;/group&gt;
    &lt;/choice&gt;
   &lt;/element&gt;
</programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
        <varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The <literal>ns</literal> attribute defines the default namespace for the elements defined in a portion of schema. The value of <literal>ns</literal> is inherited.</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry><refentry id="ch15-value">
      <refmeta>
        <refentrytitle>value</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2605840">
          <primary>value</primary>
        </indexterm>
        <refname>value</refname>
        <refpurpose>Match a text node and a value</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>pattern</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element value
{
   attribute type { xsd:NCName }?,
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   text
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>attribute</literal>, <literal>choice</literal>, <literal>define</literal>, <literal>element</literal>, <literal>except</literal>, <literal>group</literal>, <literal>interleave</literal>, <literal>list</literal>, <literal>mixed</literal>, <literal>oneOrMore</literal>, <literal>optional</literal>, <literal>start</literal>, <literal>zeroOrMore</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>datatypeName literal</para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>value</literal> pattern matches a text node against a value using the semantic of a specified datatype to perform the comparison.</para>
      </refsect1>
      <refsect1>
        <title>Restrictions:</title>
        <para>The <literal>value</literal> pattern is meant for data oriented applications and can't be used in mixed content models.</para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
    &lt;attribute name=&quot;see-also&quot;&gt;
     &lt;list&gt;
      &lt;oneOrMore&gt;
       &lt;choice&gt;
        &lt;value&gt;0836217462&lt;/value&gt;
        &lt;value&gt;0345442695&lt;/value&gt;
        &lt;value&gt;0449220230&lt;/value&gt;
        &lt;value&gt;0449214044&lt;/value&gt;
        &lt;value&gt;0061075647&lt;/value&gt;
       &lt;/choice&gt;
      &lt;/oneOrMore&gt;
     &lt;/list&gt;
    &lt;/attribute&gt;

    &lt;attribute name=&quot;available&quot;&gt;
     &lt;data type=&quot;boolean&quot;&gt;
      &lt;except&gt;
       &lt;value&gt;0&lt;/value&gt;
       &lt;value&gt;1&lt;/value&gt;
      &lt;/except&gt;
     &lt;/data&gt;
    &lt;/attribute&gt;

    &lt;attribute name=&quot;available&quot;&gt;
     &lt;data type=&quot;boolean&quot;&gt;
      &lt;except&gt;
       &lt;value type=&quot;boolean&quot;&gt;false&lt;/value&gt;
      &lt;/except&gt;
     &lt;/data&gt;
    &lt;/attribute&gt;


</programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
          
        <varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The <literal>ns</literal> attribute defines the default namespace for the elements defined in a portion of schema. The value of <literal>ns</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>type</literal>
            </term>
            <listitem>
              <para>The <literal>type</literal> attribute specifies the datatype to use to perform the comparison. Note that this is not an inherited attribute and that when it is not specified, the comparison is done using the default datatype which is the <literal>token</literal> datatype of the Relax NG built in type library which means that a string comparison will be done on the values after space normalization.</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry><refentry id="ch15-zeroOrMore">
      <refmeta>
        <refentrytitle>zeroOrMore</refentrytitle>
      </refmeta>
      <refnamediv>
        <indexterm id="IXT-id2605675">
          <primary>zeroOrMore</primary>
        </indexterm>
        <refname>zeroOrMore</refname>
        <refpurpose><literal>zeroOrMore</literal> pattern</refpurpose>
      </refnamediv>
      <refsect1>
        <title>Class:</title>
        <para>pattern</para>
      </refsect1>
      <refsynopsisdiv>
        <synopsis>
element zeroOrMore
{
   (
      attribute ns { text }?,
      attribute datatypeLibrary { xsd:anyURI }?,
      attribute * - (rng:* | local:*) { text }*
   ),
   (
      ( element * - rng:* { ... }* )
    &amp; (
         element element { ... }
       | element attribute { ... }
       | element group { ... }
       | element interleave { ... }
       | element choice { ... }
       | element optional { ... }
       | element zeroOrMore { ... }
       | element oneOrMore { ... }
       | element list { ... }
       | element mixed { ... }
       | element ref { ... }
       | element parentRef { ... }
       | element empty { ... }
       | element text { ... }
       | element value { ... }
       | element data { ... }
       | element notAllowed { ... }
       | element externalRef { ... }
       | element grammar { ... }
      )+
   )
}
</synopsis>
      </refsynopsisdiv>
      <refsect1>
        <title>May be included in:</title>
        <para><literal>attribute</literal>, <literal>choice</literal>, <literal>define</literal>, <literal>element</literal>, <literal>except</literal>, <literal>group</literal>, <literal>interleave</literal>, <literal>list</literal>, <literal>mixed</literal>, <literal>oneOrMore</literal>, <literal>optional</literal>, <literal>start</literal>, <literal>zeroOrMore</literal>.</para>
      </refsect1>
      <refsect1>
        <title>Compact syntax equivalent:</title>
        <para>pattern*</para>
      </refsect1>
      <refsect1>
        <title>Description:</title>
        <para>The <literal>zeroOrMore</literal> pattern specifies that its sub patterns considered as an ordered group must be matched zero or more time.</para>
      </refsect1>
      <refsect1>
        <title>Restrictions:</title>
        <para>The <literal>zeroOrMore</literal> pattern cannot contain attribute definitions.</para>
      </refsect1>
      <refsect1>
        <title>Example:</title>
        <programlisting>
  &lt;define name=&quot;book-element&quot;&gt;
   &lt;element name=&quot;book&quot;&gt;
    &lt;attribute name=&quot;id&quot;/&gt;
    &lt;attribute name=&quot;available&quot;/&gt;
    &lt;ref name=&quot;isbn-element&quot;/&gt;
    &lt;ref name=&quot;title-element&quot;/&gt;
    &lt;zeroOrMore&gt;
     &lt;ref name=&quot;author-element&quot;/&gt;
    &lt;/zeroOrMore&gt;
    &lt;zeroOrMore&gt;
     &lt;ref name=&quot;character-element&quot;/&gt;
    &lt;/zeroOrMore&gt;
   &lt;/element&gt;
  &lt;/define&gt;
</programlisting>
      </refsect1>
      <refsect1>
        <title>Attributes:</title>
        <variablelist>
          
          
        <varlistentry>
            <term>
              <literal>datatypeLibrary</literal>
            </term>
            <listitem>
              <para>The <literal>datatypeLibrary</literal> attribute defines the default datatype library. The value of <literal>datatypeLibrary</literal> is inherited.</para>
            </listitem>
          </varlistentry><varlistentry>
            <term>
              <literal>ns</literal>
            </term>
            <listitem>
              <para>The <literal>ns</literal> attribute defines the default namespace for the elements defined in a portion of schema. The value of <literal>ns</literal> is inherited.</para>
            </listitem>
          </varlistentry></variablelist>
      </refsect1>
    </refentry></sect1>
</chapter>
